package Ontologies;

import jade.content.Concept;

/**
 * Created with IntelliJ IDEA.
 * User: jiaka_000
 * Date: 13-5-14
 * Time: 10:21
 * <p/>
 * the response of purchase request
 */
public class PurchaseResponse implements Concept {
    /**
     * const strings for error message
     */
    private static String[] errorMsg = {"No error", "Sold out"};

    /**
     * error code to indicate error type,  0: no error, 1: this type of tree sold out
     */
    private int errorCode;


    //the bought tree's info if the purchase successfully, otherwise, all infos will keep default value,;
    private String commonName;
    private String latinName;
    private float unitPrice;
    private int quantity;

    /**
     * the default constructor to set all properties into default value.
     */
    public PurchaseResponse() {
        errorCode = -1;

        commonName = null;
        latinName = null;
        unitPrice = -1;
        quantity = -1;
    }

    public String getCommonName() {
        return commonName;
    }

    public void setCommonName(String commonName) {
        this.commonName = commonName;
    }

    public String getLatinName() {
        return latinName;
    }

    public void setLatinName(String latinName) {
        this.latinName = latinName;
    }

    public float getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(float unitPrice) {
        this.unitPrice = unitPrice;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        if (errorCode < 0 || errorCode >= errorMsg.length)
            return null;
        else {
            return errorMsg[errorCode];
        }
    }
}
